<!doctype html>
<html lang="zh">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>风之领域</title>
    <meta name="keywords" content="风之领域,风之领域写真,风之领域图片,风之领域套图">
    <meta name="description" content="在线欣赏风之领域超高清写真套图图片。">
    <meta http-equiv="Cache-Control" content="no-transform" />
    <link href="https://www.junmeitu.com/statics/css/globle.css" rel="stylesheet" type="text/css" />
    <link rel='stylesheet' id='awesome-css' href='https://cdn.bootcss.com/font-awesome/4.5.0/css/font-awesome.min.css'
        type='text/css' media='all' />
    <link rel='stylesheet'
        href='https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/lightgallery/2.4.0/css/lightgallery-bundle.min.css'
        type='text/css' media='all' />
    <script type="text/javascript" src="https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js"></script>
    <script type="text/javascript"
        src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/lightgallery/2.4.0/lightgallery.umd.min.js"></script>
    <script type="text/javascript"
        src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/lightgallery/2.4.0/plugins/thumbnail/lg-thumbnail.umd.js"></script>
    <script type="text/javascript"
        src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/lightgallery/2.4.0/plugins/zoom/lg-zoom.umd.min.js"></script>
    <script type="text/javascript"
        src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/lightgallery/2.4.0/plugins/fullscreen/lg-fullscreen.umd.min.js"></script>

</head>

<body>

    <div class="header">

        <div class="nav" style="margin-top:50px">
            <div class="w1180">

            </div>
        </div>
    </div>

    <div class="main" style="min-height:700px">
        <div class="list">

            <div class="pic-list">
                <ul class="clearfix">

                </ul>

            </div>
        </div>
        <div class="clearfix"></div>
        <!-- <div id="inline-gallery-container" class="inline-gallery-container"></div> -->
    </div>
    <footer>
    </footer>
    <script>
        function parseElement(htmlString) {
            return new DOMParser().parseFromString(htmlString, 'text/html').body.firstChild;
        }

        function loadList(data) {
            // <div class="pic-list">
            //     <ul class="clearfix">
            let ul = document.querySelector('div.pic-list > ul.clearfix')
            for (let item of data) {
                let album_title = item["album_title"]
                let cover = item["images"]["0"]["preview_url"]
                let li = `<li>
                    <a href="javascript:void(0);">
                        <img src="${cover}"
                            alt="${album_title}" />
                        <p>${album_title}</p>
                    </a>
                </li>`
                let liElement = parseElement(li)
                let dynamicEl = []
                for (let img of item['images']) {
                    dynamicEl.push({ src: img['preview_url'], thumb: img['thumb_url'], downloadUrl: img['raw_url'] })
                }
                liElement.querySelector('a').addEventListener('click', function () {

                    const dynamicGallery = lightGallery(this.parentElement, {
                        dynamic: true,
                        plugins: [lgZoom, lgThumbnail, lgFullscreen],
                        dynamicEl: dynamicEl,
                    });

                    // Since we are using dynamic mode, we need to programmatically open lightGallery
                    dynamicGallery.openGallery();
                })
                ul.appendChild(liElement)
            }

        }

        async function requestData() {
            function randomString() {
                const expect = 16;
                let str = Math.random().toString(36).substring(2);
                while (str.length < expect) {
                    str += Math.random().toString(36).substring(2);
                }
                return str.substring(0, expect);
            }
            let raw_url = 'raw.githubusercontent.com/nomeqc/static/main/data/girl-album.json'
            let apis = [`https://pic1.xuehuaimg.com/proxy/https://${randomString()}:${randomString()}@${raw_url}`,
            `https://${raw_url}`]
            for (let api of apis) {
                let result = await new Promise(resolve => {
                    $.ajax({
                        url: api,
                        type: 'GET',
                        dataType: 'json',
                        timeout: 1000 * 10,
                        success: function (data) {
                            if (data) {
                                loadList(data);
                                resolve(true);
                            } else {
                                resolve(false);
                            }
                        },
                        error: function (xhr, status, error) {
                            console.log(`${api} 请求出错。`);
                            resolve(false);
                        }
                    });
                });
                if (result) {
                    break;
                }
            }
        }
        requestData();
    </script>
</body>

</html>